<template>
  <div class="foodBuffet">
    <buffet-header/>
    <buffet-logo/>
    <buffet-recommend :list="buffetRecommendList "/>
    <buffet-footer/>
  </div>
</template>

<script>
import BuffetHeader from "./components/BuffetHeader.vue";
import BuffetLogo from "./components/BuffetLogo.vue";
import BuffetRecommend from "./components/BuffetRecommend.vue";
import BuffetFooter from "./components/BuffetFooter.vue";
import axios from "axios";
export default {
  name: "foodBuffet",
  components: {
    BuffetHeader,
    BuffetLogo,
    BuffetRecommend,
    BuffetFooter
  },
  data: function() {
    return {
      buffetRecommendList: []
    };
  },
  mounted() {
    this.getHomeApiInfo();
  },
  methods: {
    getHomeApiInfo() {
      axios
        .get("/mock/Food/buffet.json")
        .then(this.getHomeResponseInfo, function(success) {
          console.log("请求json数据成功");
          console.log(success);
        })
        .catch(function(err) {
          console.log("请求json数据失败");
          console.log(err);
        });
    },
    getHomeResponseInfo(response) {
      console.log(response.data);
      let res = response.data;
      if (res.success && res.dataList) {
        const buffetData = res.dataList;
        this.buffetRecommendList = buffetData.BuffetRecommedLists;
      }
    }
  }
};
</script>          